Methods for Opening Forms and Browses

Description

Using Xbasic you can open a form or a browse layout and you can control which records are displayed in the layout. You can open forms as regular modeless windows, or as modal windows. Browses can only be opened as modeless windows.

If you need to open a browse as a modal window, you should design a form with an embedded browse on it and then open the form as a modal window.

For example, the following Xbasic command opens the "Customer Information" form:

dim frm as P
frm = form.view("Customer Information")

Once you have a pointer to the form (i.e. "frm" in the above example), then you can use any of the form methods. For example, say that you wanted to open the "Customer Information" form, and then immediately begin entering a new record:

dim frm as P
frm = form.view("Customer Information")
frm.new_record()

Say that you wanted to open the "Customer Information" form, but only show records for customers from Massachusetts, sorted by lastname. To do this, you would use the FORM.VIEWQUERIED() method:

dim frm as P
frm = form.viewQueried("Customer Information","bill_state_region = 'MA'","lastname")

If you wanted to open "Customer Information" as a modal window, you would use the command:

dim frm as P
frm = form.viewQueried("Customer Information", "bill_state_region = 'MA'","lastname", "dialog")
frm.close()

Note the frm.close() method in the above script fragment. This is needed because when a dialog form is "closed" by the user, it is not really closed, it is just hidden so that the script that opened the dialog can read variables that the user might have filled in on the dialog. For more information on the how dialog forms work, refer to Opening a Dialog Box.

See Also